﻿#ifndef TRANSLATEHELPER_H
#define TRANSLATEHELPER_H

#include <QObject>
#include <QTranslator>
#include <QQmlEngine>

#include "../common/singleton.h"
#include "../common/stdafx.h"

class TranslateHelper : public QObject
{
    Q_OBJECT
    Q_PROPERTY_AUTO(QString, current)
    Q_PROPERTY_READONLY_AUTO(QStringList, languages)
private:
    explicit TranslateHelper(QObject *parent = nullptr);

public:
    SINGLETON(TranslateHelper)
    ~TranslateHelper() override;
    void init(QQmlEngine *engine);
    QString getLocaleLanguage();
    Q_INVOKABLE void switchLanguage(const QString &language);

private:
    QQmlEngine *_engine;
    QTranslator *_translator;
};

#endif // TRANSLATEHELPER_H
